From: Timo Tijhof Date: Fri, 23 Aug 2019 13:15:33 +0000 (+0100) Subject: filebackend: Remove private handleWarning in favour of local closure X-Git-Tag: 1.34.0-rc.0~610^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin//%22%24path/%7B%24disabledImages%5B%24type%5D%7D/%22?a=commitdiff_plain;h=bebb26eb2663a21a90dea5086f6b883b8bd6b0f7;p=lhc%2Fweb%2Fwiklou.git filebackend: Remove private handleWarning in favour of local closure This is a pattern from before PHP 5.3, which we no longer need. Change-Id: I886d1ded25ffe1ee12b6a3f8d48c04aa7dd2ef51 --- diff --git a/includes/libs/filebackend/FSFileBackend.php b/includes/libs/filebackend/FSFileBackend.php index e6a49c7dd4..c05dc286c8 100644 --- a/includes/libs/filebackend/FSFileBackend.php +++ b/includes/libs/filebackend/FSFileBackend.php @@ -795,8 +795,16 @@ class FSFileBackend extends FileBackendStore { * Listen for E_WARNING errors and track whether any happen */ protected function trapWarnings() { - $this->hadWarningErrors[] = false; // push to stack - set_error_handler( [ $this, 'handleWarning' ], E_WARNING ); + // push to stack + $this->hadWarningErrors[] = false; + set_error_handler( function ( $errno, $errstr ) { + // more detailed error logging + $this->logger->error( $errstr ); + $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true; + + // suppress from PHP handler + return true; + }, E_WARNING ); } /** @@ -805,20 +813,9 @@ class FSFileBackend extends FileBackendStore { * @return bool */ protected function untrapWarnings() { - restore_error_handler(); // restore previous handler - return array_pop( $this->hadWarningErrors ); // pop from stack - } - - /** - * @param int $errno - * @param string $errstr - * @return bool - * @private - */ - public function handleWarning( $errno, $errstr ) { - $this->logger->error( $errstr ); // more detailed error logging - $this->hadWarningErrors[count( $this->hadWarningErrors ) - 1] = true; - - return true; // suppress from PHP handler + // restore previous handler + restore_error_handler(); + // pop from stack + return array_pop( $this->hadWarningErrors ); } }